﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using BlogKickStart.Models;
using System.Data;
using System.Data.OleDb;
using System.Configuration;

namespace BlogKickStart.Controllers
{
    public class ChangeThemeController : Controller
    {
        //
        // GET: /ChangeTheme/

        public ActionResult ChangeTheme()
        {
			using (BlogKickstartContext data = new BlogKickstartContext())
			{
				var themeName = (from p in data.Blogs
								 where p.BlogID == 1
								 select p.Style.StyleNM);
				
			}
            return View();
        }

		[HttpPost]
		public ActionResult ChangeTheme(string selection)
		{
			using (BlogKickstartContext data = new BlogKickstartContext())
			{
				var theme = (from p in data.Styles
								where p.StyleNM == selection
								select p).Single();
				var blog = data.Blogs.Where(n => n.BlogID == 1).Single();
				blog.Style = theme;
				data.SaveChanges();
			}

			return RedirectToAction("Index", "BlogPost");
		}
    }
}
